Skip to content

Grammar coverage: multiple superclasses, sort-annotated & Greek type variables#8

Merged
christiankissig merged 3 commits into
masterfrom
form-level-gaps
Jun 2, 2026
Merged

Grammar coverage: multiple superclasses, sort-annotated & Greek type variables#8
christiankissig merged 3 commits into
masterfrom
form-level-gaps

Conversation

@christiankissig

Copy link
Copy Markdown
Owner

Summary

Closes the three highest-value form-level gaps identified in the refreshed coverage report (target "A"). All three were confirmed failing in isolation and are localized grammar changes.

Fix Was failing Now
Greek-letter type variables type_synonym ('\<alpha>, '\<beta>) t = … TYPE_IDENT extended to allow a \<name> symbol after ' — applies everywhere type vars occur
Multiple superclasses in class class c = foo + bar + linorder class_spec now accepts a +-separated list of parent class names, optionally followed by + <context elements>
Sort-annotated type vars in datatype datatype ('a::type) box = … datatype now uses typespec_sorts (the correct (tvar::sort, …) name shape) instead of generic_type

Testing

  • Full unit suite: 141 passed (135 baseline + 6 new cases), no regressions.
  • datatype switch regression-checked against a corpus sample of real datatype declarations: 0 new regressions vs the previous grammar (one extra declaration now parses). The pre-existing failures there are bnf-style annotations (dead 'd, leaves: 'l) unrelated to this change.
  • ruff check / ruff format / isort clean.

Not included

  • bnf datatype annotations (dead, selector name: on type args), method … for …, unbundle (in …), and the nominal_* command family remain unsupported (niche; noted in COVERAGE_REPORT.md).

🤖 Generated with Claude Code

christiankissig and others added 3 commits June 2, 2026 20:22
TYPE_IDENT only matched ASCII type variables (`'a`), so type variables
written with Greek symbols (`'\<alpha>`, `'\<beta>`) — common in the AFP —
were rejected wherever type variables appear (type_synonym, datatype,
typedef, …). Extend TYPE_IDENT to allow a `\<name>` symbol after the
apostrophe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
class_spec only allowed a single parent class name before the context
elements, so `class c = foo + bar + linorder` (a chain of superclasses,
common in algebraic-hierarchy entries) failed. Allow a `+`-separated list
of parent class names, optionally followed by `+ <context elements>`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`datatype` used `generic_type` for its left-hand side, which treats type
arguments as opaque types and rejects sort annotations like
`datatype ('a::type) box = ...`. Switch to `typespec_sorts`, which is the
correct shape for a type specification (`(tvar::sort, ...) name`) and
already handles plain and Greek type variables.

Verified against a corpus sample of real datatype declarations: 0 new
regressions vs the previous grammar (one additional declaration now
parses). Full unit suite green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@christiankissig christiankissig merged commit 067eb9f into master Jun 2, 2026
6 checks passed
@christiankissig christiankissig deleted the form-level-gaps branch June 2, 2026 20:40
christiankissig added a commit that referenced this pull request Jul 7, 2026
Grammar coverage: multiple superclasses, sort-annotated & Greek type variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant